package unimelb.distSystems.game.tools;

import com.jme3.scene.Geometry;
import com.jme3.scene.Node;
import com.jme3.scene.Spatial;

public class CustomGeometry {
	
	  public Geometry findGeom(Spatial spatial, String name) {
	        if (spatial instanceof Node) {
	            Node node = (Node) spatial;
	            for (int i = 0; i < node.getQuantity(); i++) {
	                Spatial child = node.getChild(i);
	                Geometry result = findGeom(child, name);
	                if (result != null) {
	                    return result;
	                }
	            }
	        } else if (spatial instanceof Geometry) {
	            if (spatial.getName().startsWith(name)) {
	                return (Geometry) spatial;
	            }
	        }
	        return null;
	    }
}
